﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x02000044 RID: 68
	public class NullableDoubleFormatter : IMessagePackFormatter<double?>
	{
		// Token: 0x060000FF RID: 255 RVA: 0x00004804 File Offset: 0x00002C04
		private NullableDoubleFormatter()
		{
		}

		// Token: 0x06000100 RID: 256 RVA: 0x0000480C File Offset: 0x00002C0C
		public int Serialize(ref byte[] bytes, int offset, double? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteDouble(ref bytes, offset, value.Value);
		}

		// Token: 0x06000101 RID: 257 RVA: 0x00004834 File Offset: 0x00002C34
		public double? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new double?(MessagePackBinary.ReadDouble(bytes, offset, out readSize));
		}

		// Token: 0x04000038 RID: 56
		public static readonly NullableDoubleFormatter Instance = new NullableDoubleFormatter();
	}
}
